<template>
  <div class="layout">
    <div class="fianceCon">
      <div style="display: flex; justify-content: space-between">
        <Breadcrumb class="breadcrumb" :crumbs="crumbs"></Breadcrumb>
        <!-- <div class="backBtn" @click="goBack()">返回</div> -->
      </div>

      <div class="policyMsgTable">
        <div class="mail">
          <div class="login">
            <template v-if="!detail.companyLogo">
              {{ detail.firstStr }}
            </template>
            <img v-else :src="detail.companyLogo" />
          </div>
          <div class="titleBox">
            <div class="tit">
              <span>{{ detail.financingName }}</span>
              <div class="titype">
                {{ get_company_industry_text(detail.companyIndustryVal) }}
              </div>
            </div>
            <div class="caseSun">
              <div class="sunitem">
                <span>融资类型：</span>
                <span>{{ getcingTypeVal(detail.financingTypeVal) }}</span>
              </div>
              <div class="sunitem">
                <span>融资期限：</span>
                <span>{{ detail.startTimeStr }}至{{ detail.endTimeStr }}</span>
              </div>
              <div class="sunitem">
                <span>资金用途：</span>
                <span>{{ detail.financingPurpose }}</span>
              </div>
            </div>
          </div>
          <div class="box2">
            <div>{{ getTurnVal(detail.financingTurnVal) }}</div>
            <div>{{ getStatusVal(detail.financingStatusVal) }}</div>
          </div>
          <div class="box2">
            <div>{{ getceStatusVal(detail.financeStatusVal) }}</div>
            <div>{{ detail.city }}</div>
          </div>
        </div>

        <div class="describe">
          {{ detail.financingIntroduce }}
        </div>
      </div>
      <div class="casedescribe">
        <div class="describe1">
          {{ getdescribeTypeVal(detail.describeTypeVal) }}
        </div>
        <div class="describe2">
          {{ detail.projectDescribe }}
        </div>
      </div>
      <div class="explainBox">
        <div class="explainTitle">
          <div class="tit">融资期望</div>
          <div class="con">
            <!-- 融资：￥1000万 出让股份10% 工程建设、技术设备购买与安装等。 -->
            {{ detail.financingExpect }}
          </div>
        </div>
        <div class="explainTitle" v-if="detail.projectDetails">
          <div class="tit">项目详情</div>
          <div class="con" v-html="detail.projectDetails"></div>
        </div>
        <div class="explainTitle">
          <div class="tit">公司信息</div>
          <div class="con">
            {{ detail.companyName }} <br />
            公司介绍：{{ detail.financingIntroduce || "无" }} <br />
            公司官网：{{ detail.officialWebsite || "无" }} <br />
            公司地址：{{ detail.province }}{{ detail.city }}{{ detail.county
            }}{{ detail.detailedAddress }}
          </div>
        </div>
      </div>
      <Buttons :buttons="buttons" @goBack="goBack" class="backBtn"></Buttons>
    </div>
  </div>
</template>
<script>
import { getDetailedDetails } from "@/common/api/finance"

import Breadcrumb from "@/components/breadcrumb";
export default {
  data() {
    return {
      buttons:[{text:"返回",type:"normal",size:"l",method:"goBack"}],
      crumbs: [
        {
          label: "金融服务",
          value: "finance",
        },
        {
          label: "企业融资清单",
          value: "financeenterprise",
        },
        {
          label: "企业融资详情",
          value: "",
          choose: true,
        },
      ],
      companyFinancingId: null,
      detail: {},
      typeList: [],
      turnList: [],
      desTypeList: [],
      statusList: [],
      gstatusList: [],
      company_industry: [],
    };
  },
  components: {
    Breadcrumb,
  },
  activated() {
    // 通过路由获取产品id
    if (this.$route.query.companyFinancingId) {
      this.companyFinancingId = this.$route.query.companyFinancingId;
      this.getProductDetail();
    }
  },
  created() {
    this.gettypeList();
  },
  methods: {
    /**
     * 返回上一页
     */
    goBack() {
      this.$router.back();
    },
    // 获取详情数据
    async getProductDetail() {
      // let api = `${host}/finance/companyFinancing/getDetailedDetails/${this.companyFinancingId}`;
      let { code, data, msg } = await getDetailedDetails(this.companyFinancingId)
      if (code != '200') return this.$message.warning(msg)
      // console.log("res123", res);
      
      if (data && data.companyFinancing.companyName) {
        this.detail = data.companyFinancing;
      }
      this.detail = data.companyFinancing;
      // 格式化时间
      this.detail.startTimeStr = new Date(this.detail.startTimeStr).pattern(
        "yyyy-MM-dd"
      );
      this.detail.endTimeStr = new Date(this.detail.endTimeStr).pattern(
        "yyyy-MM-dd"
      );
    },
    // 字典查询 政策类别
    async gettypeList() {
        // 调用公共方法中的查询字典表
        this.getDictList(this,`finance_financing_type,finance_financing_turn,finance_describe_type,finance_com_finance_status,finance_com_financing_status,company_industry`).then(res => {
          //  融资类型
          this.typeList = res.finance_financing_type;
          //  融资的轮次
          this.turnList = res.finance_financing_turn;
          //  项目描述类型
          this.desTypeList = res.finance_describe_type;
          //  公司财务状况
          this.statusList = res.finance_com_finance_status;
          //  公司财务状况
          this.gstatusList = res.finance_com_financing_status;
          this.company_industry = res.company_industry;
        })
    },
  },
  computed: {
    get_company_industry_text() {
      return function (value) {
        const item = this.company_industry.find((e) => e.dictValue == value);
        return item ? item.dictLabel : "";
      };
    },
    getTurnVal() {
      return function (data) {
        let turnList = this.turnList;
        let obj = turnList.find((item) => item.dictValue == data);
        return obj && obj.dictLabel;
      };
    },

    getStatusVal() {
      return function (data) {
        let turnList = this.gstatusList;
        let obj = turnList.find((item) => item.dictValue == data);
        return obj && obj.dictLabel;
      };
    },
    getceStatusVal() {
      return function (data) {
        let turnList = this.statusList;
        let obj = turnList.find((item) => item.dictValue == data);
        return obj && obj.dictLabel;
      };
    },

    getcingTypeVal() {
      return function (data) {
        let turnList = this.typeList;
        let obj = turnList.find((item) => item.dictValue == data);
        return obj && obj.dictLabel;
      };
    },
    // 项目描述类型
    getdescribeTypeVal() {
      return function (data) {
        let turnList = this.desTypeList;
        let obj = turnList.find((item) => item.dictValue == data);
        return obj && obj.dictLabel;
      };
    },
  },
};
</script>
<style scoped>
.breadcrumb {
  width: 1200px;
  margin-bottom: 30px;
}
.fianceCon {
  width: 1200px;
  margin: 0 auto;
  padding: 20px 0;
  text-align: left;
  word-break: break-all;
}
.backBtn {
  color: #045db9;
  padding: 10px 0px;
  font-size: 15px;
  border-radius: 5px;
  /* margin-right: 20px; */
  transition: all 0.2s ease 0s;
  width: 120px;
  box-sizing: border-box;
  text-align: center;
  margin: 20px auto;
}

.backBtn:hover {
  cursor: pointer;
  box-shadow: 0px 0px 5px #eeeeee;
}
.fianceCon .title {
  text-align: left;
  margin-bottom: 20px;
  display: flex;
  justify-content: space-between;
}
.fianceCon .title .tex {
  font-size: 24px;
  font-weight: 700;
}
.fianceCon .title .btn {
  width: 120px;
  height: 40px;
  line-height: 40px;
  background: #045db9;
  border-radius: 3px;
  color: #ffffff;
  text-align: center;
}
.fianceCon .policyMsgTable {
  display: flex;
  flex-direction: column;
  border: 1px solid #e1e1e1;
  font-size: 14px;
  min-height: 170px;
  margin-bottom: 20px;
  padding: 30px;
  box-sizing: border-box;
}
.fianceCon .policyMsgTable .mail {
  display: flex;
  justify-content: flex-start;
}
.fianceCon .policyMsgTable .mail .login {
  width: 80px;
  height: 80px;
  flex-shrink: 0;
  background: #045db9;
  font-size: 41px;
  font-weight: 700;
  line-height: 80px;
  color: #ffffff;
  border-radius: 50%;
  margin-right: 15px;
  text-align: center;
}
.fianceCon .policyMsgTable .mail .login img {
  width: 78px;
  height: 78px;
}
.fianceCon .policyMsgTable .mail .titleBox {
  /* flex: 1; */
  margin-top: 18px;
}
.fianceCon .policyMsgTable .mail .titleBox .tit {
  /* width: 144px; */
  display: flex;
  font-size: 24px;
  color: #333333;
  font-weight: bold;
  align-items: flex-start;
  line-height: 1;
}
.fianceCon .policyMsgTable .mail .titleBox .tit span {
  word-break: break-all;
}
.describe {
  padding-left: 100px;
  flex-wrap: wrap;
  font-size: 14px;
  color: #999999;
  margin-top: 26px;
}
.fianceCon .policyMsgTable .mail .titleBox .titype {
  font-size: 14px;
  background: rgba(252, 172, 18, 0.1);
  color: #fcac12;
  border-radius: 2px;
  padding: 3px 10px;
  margin-left: 10px;
  flex-shrink: 0;
  margin-top: 2px;
}

.fianceCon .policyMsgTable .mail .box2 {
  margin-left: 50px;
  margin-top: 18px;
  flex-shrink: 0;
}
.fianceCon .policyMsgTable .mail .box2 div:nth-child(1) {
  font-size: 24px;
  color: #045db9;
  font-weight: 400;
}
.fianceCon .policyMsgTable .mail .box2 div:nth-child(2) {
  color: #999999;
  font-size: 14px;
}
.fianceCon .policyMsgTable .caseSun {
  display: flex;
  flex-wrap: wrap;
  /* margin-left: 26px; */
}
.fianceCon .policyMsgTable .caseSun .sunitem {
  display: flex;
  margin: 5px 20px 0 0;
  font-size: 14px;
}
.fianceCon .policyMsgTable .caseSun .sunitem span:nth-child(1) {
  width: 70px;
  color: #999;
  flex-shrink: 0;
}
.fianceCon .policyMsgTable .caseSun .sunitem span:nth-child(2) {
  color: #333;
  font-weight: bold;
}
.fianceCon .casedescribe {
  display: flex;
  flex-direction: column;
  min-height: 110px;
  background: #ffffff;
  border: 1px solid #eeeeee;
  margin-bottom: 20px;
  box-sizing: border-box;
  padding: 20px 30px;
  text-align: left;
}
.fianceCon .casedescribe .describe1 {
  font-size: 18px;
  color: #333;
  font-weight: bold;
}
.fianceCon .casedescribe .describe2 {
  font-size: 14px;
  margin-top: 5px;
}
.fianceCon .explainBox {
  border: 1px solid #eeeeee;
  padding: 24px 14px;
}
.fianceCon .explainBox .explainTitle {
  margin-bottom: 30px;
}
.fianceCon .explainBox .explainTitle .tit {
  font-size: 18px;
  font-weight: 700;
  text-align: left;
  color: #045db9;
  position: relative;
  margin-left: 14px;
}
.fianceCon .explainBox .explainTitle .tit:after {
  content: "";
  position: absolute;
  left: -14px;
  top: 3px;
  width: 3px;
  height: 18px;
  background: #045db9;
}
.fianceCon .explainBox .explainTitle .con {
  font-size: 14px;
  color: #666666;
  line-height: 24px;
  text-align: left;
  margin-left: 14px;
  margin-top: 10px;
}
.fianceCon .explainBox .download {
  display: flex;
  margin-top: 30px;
  margin-left: 10px;
}
.fianceCon .explainBox .download .dowtit {
  font-size: 14px;
  color: #666666;
}
.fianceCon .explainBox .download .dowcon {
  flex: 1;
  margin-left: 12px;
  text-align: left;
}
.fianceCon .explainBox .download .dowcon .item {
  color: #045db9;
  font-size: 14px;
  margin-bottom: 12px;
}
.fianceCon .explainBox .download .dowcon .item:last-child {
  margin-bottom: 0;
}
</style>